//
//  ZPayLoseViewController.m
//  DoctorFAQs
//
//  Created by zjq on 17/2/16.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "ZPayLoseViewController.h"
#import "ZPayResultHeaderView.h"
#import "ZPayResultFootView.h"

#import "ZDoctorReplyViewController.h" // 返回回复页;
@interface ZPayLoseViewController () {
    ZPayResultHeaderView * _headerView;
    ZPayResultFootView * _footView;
    UILabel * _promptLabel;// 提示label
}

@end

@implementation ZPayLoseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initlizeInterface];
}

- (void)initlizeInterface {
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"支付结果";
    [self makeALLSubView];
    [self addALLSubView];
}
- (void)makeALLSubView {
    _headerView = [[ZPayResultHeaderView alloc] init];
    _headerView.imageView.image = [UIImage imageNamed:@"pay_fail"];
    _headerView.titleLabel.text = @"支付失败,请重新支付";
    _promptLabel = [[UILabel alloc] init];
    _promptLabel.text = @"尊敬的用户您好,您的本次支付遇到问题,为了不影响您的下次提问,请重新支付。";
    _promptLabel.textAlignment = NSTextAlignmentCenter;
    _promptLabel.textColor = [UIColor blackColor];
    _promptLabel.font = [UIFont systemFontOfSize:15];
    _promptLabel.numberOfLines = 2;
    _footView = [[ZPayResultFootView alloc] init];
    [_footView.assessBtn setTitle:@"重新支付" forState:UIControlStateNormal];
    [_footView.assessBtn addTarget:self action:@selector(assessBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [_footView.backBtn addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
}
-(void)addALLSubView {
    [self.view addSubview:_headerView];
    [self.view addSubview:_promptLabel];
    [self.view addSubview:_footView];
    [self makeALLSubViewMasnoy];
}
-(void)makeALLSubViewMasnoy {
    [_headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.top.equalTo(self.view);
        make.height.offset(195*ysIZE);
    }];
    [_promptLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(10*xsIZE);
        make.right.equalTo(self.view).offset(-10*xsIZE);
        make.height.offset(50*ysIZE);
        make.top.equalTo(_headerView.mas_bottom).offset(17.5*ysIZE);
    
    }];
    [_footView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.equalTo(self.view);
        make.top.equalTo(_promptLabel.mas_bottom).offset(75*ysIZE);
        make.height.offset(40*ysIZE);
    }];
}

// 重新支付的按钮
- (void)assessBtnAction:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
// 返回回复页的按钮
- (void)backButtonAction:(UIButton *)sender {
    NSArray *temArray = self.navigationController.viewControllers;
    for (UIViewController * vc in temArray) {
        if ([vc isKindOfClass:[ZDoctorReplyViewController class]]) {
            [self.navigationController popToViewController:vc animated:YES];
        }
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
